<include file="public@header" />
<head>
    <title></title>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <style type="text/css">
        body {
            padding-bottom: 60px !important;
            font-family: 'Microsoft YaHei' !important
        }

        .icon {
            margin: 0 3px -2px -27px;
            width: 1em;
            height: 1em;
            vertical-align: -0.15em;
            fill: currentColor;
            overflow: hidden;
            font-size: 20px;
        }
        body{ padding-bottom:8px!important}
        div.qian{border-bottom:1px dotted #777;padding:10px}
        div.qian>p{margin:3px 15px 0}
        mark{padding:2px 5px 0;color:red}
        mark1{padding:2px 5px 0;color:#005291;}
        mark.red{background-color:#feb08e}
        .qian .form-group .control-label{ padding-top: 5px; text-align: center;}
    </style>

</head>
<body>
<div class="col-md-10">
    <div class="" style="color:#000!important">
        <div class="" style="font-size:16px!important">
            <div style="border-bottom:1px dashed #333;padding:5px;" id="zzz">
                <i class="fa fa-user"> </i> {$result.buyer_name}
                <i class="fa fa-phone" style="margin-left:20px"> </i> {$result.buyer_phone}
                <i class="fa fa-newspaper-o" style="margin-left:20px"> </i> {$result.tomb_num}
            </div>
            <div class='qian qt '>
                <div class="form-group">提交人：{$receptionist}<span style='margin-left:20px' class='sj'>提交时间：{$pay_info.add_time|date='Y-m-d H:i:s'}</span></div>

                <div class="form-group  "> {$html}</div>
                <div class="form-group" >
                    <div class="col-md-12" style="padding-left: 0;padding-right: 0;">
                        <label class="control-label" style="width: 80px">付款方式：</label>
                        <select id="pt" class="form-control">
                            <option value="1" <if condition="$pay_info.pay_type eq 1">selected</if> >现金</option>
                            <option value="2" <if condition="$pay_info.pay_type eq 2">selected</if> >转账</option>
                            <option value="3" <if condition="$pay_info.pay_type eq 3">selected</if> >电汇</option>
                            <option value="4" <if condition="$pay_info.pay_type eq 4">selected</if> >微信</option>
                            <option value="5" <if condition="$pay_info.pay_type eq 5">selected</if> >支付宝</option>
                            <option value="6" <if condition="$pay_info.pay_type eq 6">selected</if> >其他</option>
                        </select>
                        <label class="control-label" style="width: 75px; ">付款人：</label>
                        <input type="text" id="rn"   style="width: 120px; " class="form-control" placeholder="请输入姓名"  value="{$pay_info.real_name}">
                        <label class="control-label" style="width: 130px;">付款人联系电话：</label>
                        <input type="text"  id="rp" style="width: 130px; "  class="form-control" placeholder="请输入手机号" value="{$pay_info.real_phone}">
                    </div>
                </div>
                <div class="form-group" >
                    <div class="col-md-12" style="padding-left: 0;padding-right: 0;">
                        <label class="control-label" style="width: 80px">备注：</label>
                        <input type="text"  id="rk" style="width: 450px; "  class="form-control" placeholder="备注信息" value="{$pay_info.remark}">
                    </div>
                </div>
                <div class="form-group pp " style="text-align:right;" cid="{$result.customer_id|default=''}"
                     oid="{$result.order_id|default=''}" mwid="{$result.tomb_id|default=''}"
                     pid="{$pay_info.id}" t="{$pay_info.type}" it="{$pay_info.itype}" qtid="{$pay_info.other_id}">
                    <div class="btn btn-primary settlement" data-index="2" >预览单据</div>
                    <if condition="$menu eq 1">
                        <div class="btn btn-primary settlement" data-index="0" >完成结款</div>
                        <div class="btn btn-primary settlement" data-index="1" >业务取消</div>
                    </if>
                </div>
                <input type="hidden" name="pay_id"   value="{$pay_info.id}">
                <input type="hidden" name="tomb_type"   value="1">
                <input type="hidden" name="dtype" id="otype" value="4">
                <input type="hidden" name="order_id" value="{$result.order_id|default=''}">
                <input type="hidden" name="tomb_id" value="{$result.tomb_id|default=''}">
                <input type="hidden" name="tomb_num" value="{$result.tomb_num|default=''}">
                <input type="hidden" name="customer_id" value="{$result.customer_id|default=''}">
                <input type="hidden" name="deposit_id" value="{$restl.deposit_id|default=''}">
            </div>
        </div>
    </div>

</div>
<iframe id="printf" src="" width="0" height="0" frameborder="0"></iframe>
<div id="print_html" style="display: none"></div>
<script type="text/javascript" src="__STATIC__/js/lodop/LodopFuncs.js?v={:time()}"></script>
<script language="javascript" type="text/javascript">
    var LODOP; //声明为全局变量

</script>
<script type="text/javascript" src="__STATIC__/js/admin.js?v={:time()}"></script>
<script>
    $("div.qian .settlement").click(function () {
        var z3 = $(this);
        var z4 = z3.parent();
        var fids = [];
        z4.prevAll("p[fid!='']").each(function () {
            fids[fids.length] = $(this).attr("fid");
        });
        var rn = $('#rn').val(), pt = $('#pt').val(), rh = $('#rp').val(), rk = $('#rk').val();
        if (z3.data('index') == 1) {
            layer.confirm("请慎重操作，确定要取消这笔业务吗？取消相关内容被删除，无法找回，请重新提交相关内容", {
                icon: 3,
                title: "提示", btn: ['确定', '暂不']
                , btn1: function () {
                    $.ajax({
                        type: "POST",
                        url: "{:url('feil_delf')}",
                        data: {pid:z4.attr("pid")},
                        dataType: "json",
                        success: function (r) {
                           if (r.code == 1) {
                               layer.alert(r.msg, {icon: 1, yes: function (index) {
                                       layer.close(index);
                                       parent.location.reload();
                               }})
                            }else {
                               layer.alert(r.msg, {icon:5, yes: function (index) {
                                   }})
                           }
                        }
                    });
                }
                , btn2: function () {
                    layer.closeAll();
                }
            });
        } else if (z3.data('index') ==2) {
            $.ajax({type: "POST", url: "{:url('shoufei_ajax')}",
                data: {yl:1,pt:pt,rn:rn,rh:rh,rk:rk,t:z4.attr("t"),it:z4.attr("it"),pid:z4.attr("pid"),qtid:z4.attr("qtid"),oid:z4.attr('oid'),cid:z4.attr('cid')},
                dataType: "json", success: function (r) {
                    console.log(r)
                    if (r.code == 1) { layer.alert(r.msg, { icon: 5 });
                    }else {
                        // window.open( r.danju_url, 'n3', "height=990,width=1100");
                        // window.open('{:url("Print/muzheng")}', "n3", "height=800,width=1100");
                        $.ajax({
                            type: "get", url: r.danju_url,
                            success: function (strHtml) {
                                console.log('打印')
                                var data = strHtml.data;
                                $('#print_html').html(data.html)
                                preViewPrint(data.head_title,data.type,data.itype,1)
                            }
                        })
                    }
                }
            });
        } else if (z3.data('index') == 0) {
            layer.confirm("这笔款确定结清吗？", {
                icon: 3,
                title: "提示", btn: ['确定', '没有']
                , btn1: function () {
                    $.ajax({type: "POST", url: "{:url('shoufei_ajax')}",
                        data: {yl:0,pt:pt,rn:rn,rh:rh,rk:rk,t:z4.attr("t"),it:z4.attr("it"),pid:z4.attr("pid"),qtid:z4.attr("qtid"),oid:z4.attr('oid'),cid:z4.attr('cid')},
                        dataType: "json", success: function (r) {
                            console.log(r)
                            if (r.code == 1) { layer.alert(r.msg, { icon: 5 }); }
                            else {
                                localStorage.setItem("jsdj", JSON.stringify(r.data));
                                var sju = z3.prev().children("mark").hasClass("red") ? "shouju_tui" : "shouju";
                                var t=r.type,it = r.itype;
                                // z4.parent().remove();
                                var L;
                                if (r.cw == "l") { L = "&l=l"; } else { L = ""; }
                                if (it==3 || it==7){
                                    layer.confirm("操作成功！", {
                                        icon: 1, btn: ['打印收据', '打印逝者', '关闭']
                                        , btn1: function () {
                                            $.ajax({
                                                type: "get", url: r.danju_url,
                                                success: function (strHtml) {
                                                    console.log('打印')
                                                    var data = strHtml.data;
                                                    $('#print_html').html(data.html)
                                                    preViewPrint(data.head_title,data.type,data.itype)
                                                    parent.layer.closeAll();
                                                    location.reload();
                                                }
                                            })

                                        },
                                        btn2: function () {
                                            $.post("{:url('ajax_print')}",{type:3,czrid:z4.attr('cid')}, function(result){
                                                console.log(result)
                                                layer.closeAll();
                                                localStorage.setItem("mz", JSON.stringify(result.data));
                                                window.open("{:url('print/muzheng')}?type=1", false);
                                            }, 'json');
                                        },
                                        btn3: function () {
                                            parent.layer.closeAll();
                                            parent.location.reload();
                                        }
                                    });
                                } else {
                                    layer.confirm("操作成功！", {
                                        icon: 1, btn: ['打印收据', '关闭']
                                        , btn1: function () {
                                            $.ajax({
                                                type: "get", url: r.danju_url,
                                                success: function (strHtml) {
                                                    console.log('打印')
                                                    var data = strHtml.data;
                                                    $('#print_html').html(data.html)
                                                    preViewPrint(data.head_title,data.type,data.itype)
                                                    parent.layer.closeAll();
                                                    location.reload();
                                                }
                                            })

                                        },
                                        btn2: function () {
                                            parent.layer.closeAll();
                                            parent.location.reload();
                                        }
                                    });
                                }

                                

                            }
                        }
                    });
                }
                , btn2: function () {
                    layer.closeAll();
                }
            });
        }
    });

    var zx = 0, zxstr;
    $("div.qian").each(function () {
        var x = 0;
        var ys = 0;
        $(this).find("mark").each(function () {
            if ($(this).hasClass("red")) {
                x = x - Number(this.innerHTML);
            } else if ($(this).hasClass("ys")) {
                ys = ys + Number(this.innerHTML);
            } else {
                x = x + Number(this.innerHTML);
            }
        });
        zx += x;
        console.log(x)
        if (x >= 0) {
            $(this).children(".pp").prepend("<div style='float:left;margin-top:10px'>这笔合计应收<mark >" + x + "</mark>元</pre>");
        } else {
            $(this).children(".pp").prepend("<div style='float:left;margin-top:10px'>这笔合计应退<mark class='red'>" + eval(0 - x) + "</mark>元</pre>");
        }
    });
    if (zx >= 0) {
        zxstr = "合计应收<mark>" + zx + "</mark>元";
    } else {
        zxstr = "合计应退<mark class='red'>" + zx + "</mark>元";
    }
    $("#zzz").append("<span style='margin-left:20px'>" + zxstr + "</span>");

</script>
<script language="javascript" type="text/javascript">
    var LODOP; //声明为全局变量

</script>

<script type="text/javascript" src="__STATIC__/js/print.js?v={:time()}"></script>
</body>
</html>


